﻿Public Class ucBanHang
    'biến lưu tên user control nhấn vào sau cùng
    Public TenUserControl As String

    'Hàm thêm user control lên  pnBanHang
    Public Sub ThemUserControl(uc As UserControl)
        If uc.Name <> TenUserControl Then
            TenUserControl = uc.Name
            pnBanHang.Controls.Clear()
            uc.Dock = DockStyle.Fill
            pnBanHang.Controls.Add(uc)
        End If
    End Sub

    Private Sub ucBanHang_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim uc As New ucPhieuBanHang
        uc.Dock = DockStyle.Fill
        pnBanHang.Controls.Add(uc)
        TenUserControl = uc.Name
        lbBanHang.Text = "Phiếu Xuất Hàng"
    End Sub


    Private Sub btnPhieuBanHang_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnPhieuBanHang.LinkClicked
        Dim uc As New ucPhieuBanHang
        lbBanHang.Text = btnPhieuNhapHang.Caption
        ThemUserControl(uc)
        navThemDanhMuc.Visible = True
    End Sub


    Private Sub btnTheoHangHoaBH_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnTheoHangHoaBH.LinkClicked
        Dim uc As New ucTheoHangHoaBH
        lbBanHang.Text = "Bảng Kê Chi Tiết"
        ThemUserControl(uc)
        navThemDanhMuc.Visible = False
    End Sub

    Private Sub btnTheoChungTuBH_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnTheoChungTuBH.LinkClicked
        Dim uc As New ucTheoChungTuBH
        lbBanHang.Text = "Bảng Kê Tổng Hợp"
        ThemUserControl(uc)
        navThemDanhMuc.Visible = False
    End Sub

    Private Sub btnHangHoa_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnHangHoa.LinkClicked
        Dim frm As New frmThemHangHoa
        frm.ShowDialog()
    End Sub

    Private Sub btnKhachHang_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnKhachHang.LinkClicked
        Dim frm As New frmThemKhachHang
        frm.ShowDialog()
    End Sub

    Private Sub btnKhoHang_LinkClicked(sender As Object, e As DevExpress.XtraNavBar.NavBarLinkEventArgs) Handles btnKhoHang.LinkClicked
        Dim frm As New frmThemKhoHang
        frm.ShowDialog()
    End Sub
End Class
